/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import model.Usuario;

/**
 *
 * @author aluno
 */
public class GerenciadorLogin {

    public boolean validarUsr(Usuario usr) {
        GerenciadorBanco.conect();
        boolean retorno = false;
        try {
            GerenciadorBanco.conect();
            Statement stm = GerenciadorBanco.conn.createStatement();
            ResultSet lala = stm.executeQuery("SELECT * FROM usuarios where login=" + "'" + usr.login + "'" + " and senha=" + "'" + usr.senha + "'");
            if (lala.next()) {
                Usuario conf = new Usuario();
                conf.login = lala.getString("login");
                conf.senha = lala.getString("senha");
                if (conf.login.equals(usr.login) && conf.senha.equals(usr.senha)) {
                    retorno = true;
                }
            }
        } catch (SQLException ex) {
            ex.printStackTrace();
        } finally {
        }
        return retorno;
    }
}
